<script>
<!--
var sort_by = '';
var sort_order = 0;
var current_view = '';
var page = 1;

function listReload(page)
{
    $('#indexAjax').html('<div align="center"><div class="loader_admin"></div></div>');
    $('#indexAjax').load('<?php echo url_for('@cms_edit?cms_id='.$cms->cms_id) ?>?'+$('#filterSearch').serialize(), {
        sort_by:      sort_by,
        sort_order:   sort_order,
        page:         page,
        view:         current_view,
    });
}
-->
</script>
<div class="row-fluid">
    <div class="span12">
        <div class="box gradient">
            <div class="title">
                <h4>
                    <span>Sửa Bài viết</span>
                </h4>
            </div>
            <div class="content" id="EditCmsForm">
            	<form class="form-horizontal" id="form-cms-validate" action="<?php echo url_for('@cms_edit?cms_id='.((isset($cms))? ($cms->cms_id):"").''); ?>" method="post" enctype="multipart/form-data">
                	<div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_form['name']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_form['name']->render(array("id" => "cms_name"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_form['cms_category_id']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_form['cms_category_id']->render(array("class" => "nostyle", "style" => "width:100%", "id" => "cms_category_id"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_form['picture']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_form['picture']->render(array("id" => "file"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <?php if(isset($cms) && $cms->picture != null): ?> 
                    <div class="form-row row-fluid">
                    	<div class="span8">
                        	<div class="span3"></div>
                            <div class="span8 controls">			
                                <img style="max-width: 200px; max-height: 200px;" src="/uploads/cms/<?php echo $cms->picture;?> "/>
                            </div>
                    	</div>
                    </div>
                    <?php endif ?>
                    
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_form['description']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_form['description']->render(array("id" => "cms_description", "class" => "cms_description")); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_form['content']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_form['content']->render(array("id" => "textarea", "class" => "tinymce")); ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_form['link']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_form['link']->render(array("id" => "cms_link"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_form['tags']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<?php echo $cms_form['tags']->render(array("id" => "tags", "style" => "width:100%"));  ?>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-row row-fluid">
                        <div class="span8">
                            <div class="row-fluid">
                                <?php echo $cms_form['is_active']->renderLabel(null, array("class"=>"form-label span3"));  ?>
                                <div class="span8 controls">
                                	<div class="left marginR10">
                                		<?php echo $cms_form['is_active']->render(array("class" => "ibutton"));  ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php echo $cms_form['_csrf_token'];  ?>
      				<div class="form-row row-fluid">                              
                        <div class="span12">
                            <div class="row-fluid">
                                <div class="form-actions">
                                <div class="span3"></div>
                                <div class="span9 controls">
                                    <button type="submit" class="btn marginR10">Lưu thay đổi</button>
                                    <button class="btn btn-danger">Làm lại</button>
                                </div>
                                </div>
                            </div>
                        </div>
                    </div>
    				<?php if (isset($status) && $status == false) : ?>
                    <div class="form-row row-fluid">
                        <div class="span12">
                            <div class="row-fluid">
                                <div class="alert alert-error">Tin tức không đúng</div>
                                <script>
                                    alert("Tên đã tồn tại");
                                    window.location.href = document.location.href;
                                </script>
							</div>
						</div>
					</div>
                    <?php endif ?>
  				</form>
			</div>
		</div>
	</div>
</div>

<div style='padding-top:10px;'>
<div class="UITable">
  <div id="indexAjax" class='filter_form'>
    <?php include 'cmsListAjax.php' ?>
  </div>
</div>
</div>